﻿<template>
    <div>
        <div :style="{ padding: '24px', minHeight: '480px', background: '#fff' }">
            <el-row style="margin-bottom:12px">
                <el-button size="small" v-on:click="add()" type="primary">创建入库单</el-button>
                <el-button style="float:right" size="small" v-on:click="customPrint()" type="success">自定义打印</el-button>
            </el-row>
            <el-form ref="queryParams" inline label-position="right" label-width="80px" v-model="queryParams">
                <el-form-item label="供应商">
                    <el-input size="small" v-model="queryParams.supplier" @keyup.enter.native="search()" placeholder="供应商" style="width: 160px" />
                </el-form-item>
                <el-form-item label="批次号">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.billId" placeholder="批次号" style="width: 180px" />
                </el-form-item>
                <el-form-item :label="$t('出货时间')">
                    <el-date-picker size="small" value-format="yyyy-MM-dd" type="daterange" @change="cbotime" v-model="others.botime" :start-placeholder="$t('开始时间')" :end-placeholder="$t('开始时间')" style="width: 250px"></el-date-picker>
                </el-form-item>
                <el-form-item :label="$t('到仓时间')">
                    <el-date-picker size="small" value-format="yyyy-MM-dd" type="daterange" @change="cbtime" v-model="others.btime" :start-placeholder="$t('开始时间')" :end-placeholder="$t('到仓时间')" style="width: 250px"></el-date-picker>
                </el-form-item>
                <el-form-item :label="$t('入库时间')">
                    <el-date-picker size="small" value-format="yyyy-MM-dd" type="daterange" @change="cbstime" v-model="others.bstime" :start-placeholder="$t('开始时间')" :end-placeholder="$t('开始时间')" style="width: 250px"></el-date-picker>
                </el-form-item>
                <el-form-item label="商品名">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.productName" placeholder="商品名" style="width: 180px" />
                </el-form-item>
                <el-form-item label="属性规格">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.variationName" placeholder="属性规格" style="width: 180px" />
                </el-form-item>
                <el-form-item label="sku编码">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.skuCode" placeholder="sku编码" style="width: 180px" />
                </el-form-item>
                <el-form-item label="类型">
                    <el-radio-group v-model="queryParams.counter">
                        <el-radio label="">所有</el-radio>
                        <el-radio :label="1">整柜</el-radio>
                        <el-radio :label="0">散货</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="柜号">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.counterNo" placeholder="柜号" style="width: 180px" />
                </el-form-item>
                <el-form-item label="备注">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.remark" placeholder="备注" style="width: 180px" />
                </el-form-item>
                <el-form-item label="采购单">
                    <el-input size="small" @keyup.enter.native="search()" v-model="queryParams.purchaseId" placeholder="采购单" style="width: 180px" />
                </el-form-item>
                <el-form-item>
                    <el-button size="small" v-on:click="search()" type="primary">{{ $t('搜索') }}</el-button>
                    <el-button size="small" v-on:click="reset()">{{ $t('重置') }}</el-button>
                </el-form-item>
            </el-form>
            <el-row :style="{ marginBottom: '15px' }">
                <font color="#f00">{{ $t("海运费用") }}：</font>
                <el-button :type="queryParams.feeState == null ? 'danger' : 'default'" @click="queryParams.feeState = null; search()" size="small">全部</el-button>
                <el-button :type="queryParams.feeState == 1 ? 'danger' : 'default'" @click="queryParams.feeState = 1; search()" size="small">已扣费</el-button>
                <el-button :type="queryParams.feeState == 0 ? 'danger' : 'default'" @click="queryParams.feeState = 0; search()" size="small">待支付</el-button>
                <el-divider direction="vertical"></el-divider>
                <font color="#f00">{{ $t("仓库筛选") }}：</font>
                <el-button :type="queryParams.warehouseId == null ? 'danger' : 'default'" @click="fitlerWarehouse(null)" size="small">全部</el-button>
                <el-button size="small" v-for="ware in warehouses" :key="ware.id" :type="queryParams.warehouseId == ware.warehouseId ? 'success' : 'default'" @click="fitlerWarehouse(ware)">{{ ware.name }}</el-button>
                <el-button type="danger" :loading="loadingWarehouse" @click="getWarehouses" size="small">获取仓库信息</el-button>
                <el-divider direction="vertical"></el-divider>
                <font color="#f00">{{ $t("批量操作") }}：</font>
                <el-button type="success" size="small" @click="exportDetail">导出明细</el-button>
                <el-button type="primary" size="small" @click="setFreight">设置运费</el-button>
            </el-row>
            <el-row :style="{ marginBottom: '15px' }">
            </el-row>
            <el-row style="margin-bottom:12px">
                <el-select size="small" @change="page.current = 1; getList();" v-model="page.pageSize" style="width: 120px;float: left;">
                    <el-option :value="10">每页10条</el-option>
                    <el-option :value="20">每页20条</el-option>
                    <el-option :value="30">每页30条</el-option>
                    <el-option :value="50">每页50条</el-option>
                </el-select>
                <el-button size="small" @click="handleSelectionAll">{{ selectAll ? '取消全选' : '全部选择' }}
                </el-button>
                <el-button size="small" :type="queryParams.state == '' ? 'success' : 'default'" @click="searchOrder('', '')">全部</el-button>
                <el-button size="small" :type="queryParams.state == '0' ? 'success' : 'default'" @click="searchOrder('0', '')">待出货
                    <el-badge :value="billData.billCount"></el-badge>
                </el-button>
                <el-button size="small" :type="queryParams.state == '1' && queryParams.back == '' ? 'success' : 'default'" @click="searchOrder('1', '')">运送中
                    <el-badge :value="billData.billCountShip"></el-badge>
                </el-button>
                <el-button size="small" :type="queryParams.state == '2' && queryParams.back == '4' ? 'success' : 'default'" @click="searchOrder('2', '4')">已入库
                </el-button>
                <el-button size="small" :type="queryParams.state == '2' && queryParams.back == '1' ? 'success' : 'default'" @click="searchOrder('2', '1')">到仓处理中<el-badge :value="billData.billCountSign"></el-badge>
                </el-button>
                <el-button size="small" :type="queryParams.state == '2' && queryParams.back == '2' ? 'success' : 'default'" @click="searchOrder('2', '2')">异常待确认<el-badge :value="billData.billCountBack"></el-badge>
                </el-button>
                <el-divider direction="vertical"></el-divider>
                <font color="#f00">{{ $t("待付海运费") }}：</font>{{ freightData.doPay }}m³
                <el-button type="danger" size="mini" :loading="refreshLoading" icon="el-icon-refresh" @click="getFreightData()" circle></el-button>
            </el-row>
            <el-table size="small" ref="tbProducts" :data="storageBills" border style="width: 100%" v-loading="loading" small sum-text="合计" :summary-method="getSummaries" show-summary @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column align="center" prop="id" label="箱数" width="120">
                    <template slot-scope="scope">
                        <div>{{ scope.row.boxCount }}</div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="id" label="体积(m³)" width="120">
                    <template slot-scope="scope">
                        <div>{{ scope.row.volume }}</div>
                        <div class="state-error">{{ scope.row.realVolume }}</div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="id" label="海运费" width="120">
                    <template slot-scope="scope">
                        <div v-if="scope.row.feeState == 1">{{ scope.row.fee }}</div>
                        <span v-else class="state-error-full">待扣费</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="id" fixed="left" label="批次号" width="180">
                    <template slot-scope="scope">
                        <div>ID:{{ scope.row.id }}</div>
                        <div>{{ scope.row.billId }}</div>
                        <div>{{ scope.row.warehouseName }}</div>
                        <div>
                            <div v-if="scope.row.counter == 1">
                                <span class="state-success-full">整柜</span>
                                <div>{{ scope.row.counterNo }}</div>
                            </div>
                            <span class="state-error-full" v-else>散货</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="state" label="运送状态" width="180">
                    <template slot-scope="scope">
                        <span v-if="scope.row.state == 1" class="state-primary-full">在途</span>
                        <span v-if="scope.row.state == 2" class="state-success-full">已到仓</span>
                        <span v-if="scope.row.state == -1" class="state-error-full">已取消</span>
                        <span v-if="scope.row.state == 0" class="state-warning-full">待出货</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="description" label="描述" width="180">
                </el-table-column>
                <el-table-column align="center" prop="back" label="确认状态" width="180">
                    <template slot-scope="scope">
                        <div v-if="scope.row.state > 1">
                            <span v-if="scope.row.back == 0" class="state-info-full">待处理</span>
                            <span v-if="scope.row.back == 1" class="state-info-full">处理中</span>
                            <span v-if="scope.row.back == 2" class="state-warning-full">待确认</span>
                            <span v-if="scope.row.back == 4" class="state-success-full">已入库</span>
                        </div>
                        <span v-if="scope.row.state == 0" class="state-info-full">待出货</span>
                        <span v-if="scope.row.state == 1" class="state-info-full">未到仓</span> <span v-if="scope.row.state == -1" class="state-error-full">已取消</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="remark" label="用户备注" width="180">
                    <template slot-scope="scope">
                        <div @click="setRemark(scope.row)">{{ scope.row.remark }}
                            <i class="el-icon-edit" />
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="sysRemark" label="系统备注" width="180">
                    <template slot-scope="scope">
                       
                        <div>
                            <span>{{ scope.row.sysRemark }}</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="state" label="时间" width="220">
                    <template slot-scope="scope">
                        <div>
                            <span>创建时间:{{ scope.row.createTime | long2datetime }}</span>
                        </div>
                        <div v-if="scope.row.state == -1">
                            <span>取消时间:{{ scope.row.cancelTime | long2datetime }}</span>
                        </div>
                        <div v-if="scope.row.state > 0">
                            <span>出货时间:{{ scope.row.shipTime | long2datetime }}</span>
                        </div>
                        <div v-if="scope.row.state > 1">
                            <span>到仓时间:{{ scope.row.signTime | long2datetime }}</span>
                        </div>
                        <div v-if="scope.row.back == 4">
                            <span>入库时间:{{ scope.row.okTime | long2datetime }}</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" fixed="left" prop="state" label="操作" width="220">
                    <template slot-scope="scope">
                        <el-button size="small" type="success" v-on:click="toShip(scope.row)" v-if="scope.row.state == 0">出货</el-button>
                        <el-button size="small" type="warning" v-on:click="toCancel(scope.row)" v-if="scope.row.state == 0 || scope.row.state == 1">取消</el-button>
                        <!--   <el-button size="small" type="danger" v-on:click="toDelete(scope.row)" v-if="scope.row.state==-1">删除</el-button> -->
                        <el-button size="small" type="danger" v-on:click="toModify(scope.row)" v-if="scope.row.state <= 2 && scope.row.state >= 0">修改</el-button>
                        <el-button size="small" type="warning" v-if="scope.row.state == 2 && scope.row.back == 2" @click="toOk(scope.row)">确认库存</el-button>
                        <el-button size="small" type="warning" v-if="scope.row.state == 2 && scope.row.back == 4 && scope.row.feeState == 0" @click="toPay(scope.row)">支付海运费用</el-button>
                        <div style="margin-top: 10px">
                            <el-button size="small" type="info" v-on:click="toOk(scope.row)">详情</el-button>
                            <el-dropdown style="margin-left: 10px">
                                <el-button size="small" type="success">
                                    更多操作<i class="el-icon-arrow-down el-icon--right"></i>
                                </el-button>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item @click.native="printType('printSku', scope.row)">打印SKU</el-dropdown-item>
                                    <el-dropdown-item @click.native="printType('printBox', scope.row)">打印箱号</el-dropdown-item>
                                    <el-dropdown-item @click.native="exportExcel(scope.row)">导出明细</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                    <el-pagination background :page-size="page.pageSize" layout="total, prev, pager, next" :total="page.total" @current-change="changePage">
                    </el-pagination>
                </div>
            </div>
        </div>
        <CPrintSku ref="refPrintSku" @boxCallBack="skuCallBack" :billId="storageBill.id"></CPrintSku>
        <CPrintBox ref="refPrintBox" @boxCallBack="boxCallBack" :billId="storageBill.id"></CPrintBox>
        <CPrintOther ref="refPrintOther" @boxCallBack="otherCallBack"></CPrintOther>
        <CStorageBill ref="dialogBill" @ok="getList()" :id="storageBill.id"></CStorageBill>
        <CStorageBillFee ref="dialogPayBill" @ok="getList()" @cancel="getList()"></CStorageBillFee>
        <CStorageBillBatchFee ref="dialogBatchPayBill" @ok="getList()" @cancel="getList()"></CStorageBillBatchFee>
        <CStoragebillRemark ref="remarkDialog" @ok="getList()" />
        <CStorageBillEdit ref="billEditDialog" @ok="getList()" />
    </div>
</template>
<script>
import api from "@/api/api"
import CPrintBox from "./CPrintBox.vue"
import CPrintSku from "./CPrintSku.vue"
import CStorageBill from "./CStorageBill.vue"
import CStoragebillRemark from "./CStoragebillRemark.vue"
import CStorageBillEdit from "./CStorageBillEdit.vue"
import CStorageBillFee from "./CStorageBillFee.vue"
import CStorageBillBatchFee from "./CStorageBillBatchFee.vue"
import CPrintOther from "./CPrintOther.vue"
import { getRand } from "@/utils/random"
import { signGetParams } from '@/utils/sign'
import CPrintSet from "./CPrintSet.vue"
import { getStorageBillList, getWmsList } from "@/api/ProductApi"
import iNotify from '@/assets/iNotify'
export default {
    name: 'StorageBill',
    data() {
        return {
            selectAll: false,
            freightData: {
                doPay: 0
            },
            multipleSelection: [],
            refreshLoading: false,
            others: {
                bstime: [],
                botime: [],
                btime: []
            },
            warehouses: [],
            loadingWarehouse: false,
            printerShow: false,
            printers: [],
            printName: "",
            socket: null,
            loading: false,
            queryParams: {
                counter: '',
                state: '',
                back: '',
                purchaseId: '',
                feeState: null
            },
            storageBill: {

            },
            page: {
                total: 0,
                current: 1,
                pageSize: 10
            },
            storageBills: [

            ],

            billData: {
                billCount: 0,
                billCountShip: 0,
                billCountSign: 0,
                billCountBack: 0,
            }

        };
    },
    computed: {
        /**
        billCount: function() {

            return this.$store.state.notify.notifyCount.billCount;

        },
        billCountShip: function() {

            return this.$store.state.notify.notifyCount.billCountShip;

        },

        billCountSign: function() {

            return this.$store.state.notify.notifyCount.billCountSign;
        },
        billCountBack: function() {

            return this.$store.state.notify.notifyCount.billCountBack;
        }
        **/
    },
    mounted: function() {
        this.getData();
        this.getList();
        this.getWarehouses();
        this.initPrint();
        this.getFreightData();

    },
    components: {
        CPrintBox,
        CPrintSku,
        CStorageBill,
        CStorageBillFee,
        CStorageBillBatchFee,
        CPrintOther,
        CPrintSet,
        CStoragebillRemark,
        CStorageBillEdit
    },
    methods: {

        exportExcel(row) {
            var url = (process.env.NODE_ENV == 'production' ? api.root : api.testRoot) + "/storagebill/export.do?";
            let params = { id: row.id };
            params.nonceStr = getRand();
            let dt = signGetParams(params);
            url += dt;
            params.nonceStr = "";
            window.open(url.substring(0, url.length));
        },
        getIds: function() {
            var ids = [];
            for (var i = 0; i < this.multipleSelection.length; i++) {

                ids.push(this.multipleSelection[i].id);
            }
            return ids.join(",");
        },
        setFreight() {
            if (this.multipleSelection.length <= 0) {
                this.errorMessage("请先选择要设置的入库单！");
                return;
            }
            this.$refs['dialogBatchPayBill'].showDialog(this.multipleSelection);

        },
        exportDetail() {
            if (this.multipleSelection.length <= 0) {
                this.errorMessage("请先选择要导出的入库单！");
                return;
            }
            var url = (process.env.NODE_ENV == 'production' ? api.root : api.testRoot) + "/storagebill/batchExport.do?";
            let params = { ids: this.getIds() };
            params.nonceStr = getRand();
            let dt = signGetParams(params);
            url += dt;
            params.nonceStr = "";
            window.open(url.substring(0, url.length));
        },
        handleSelectionAll() {
            this.selectAll = !this.selectAll;
            this.$refs['tbProducts'].toggleAllSelection();
        },
        handleSelectionCancle(val) {
            this.selectAll = false;
            this.$refs['tbProducts'].clearSelection();
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        setRemark(row) {
            this.$refs['remarkDialog'].showDialog(row.id, row.remark);
        },
        getFreightData: function() {


            var me = this;

            me.refreshLoading = true;
            me.$http.post("/stastis/getFreight.do", { warehouseId: me.queryParams.warehouseId }).then(response => {

                var body = response;
                me.refreshLoading = false;
                if (body.status == 0) {

                    me.freightData = body.obj;

                } else {
                    me.errorMessage(body.info);
                }

            }, response => {
                me.refreshLoading = false;
            });

        },
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            columns.forEach((column, index) => {
                if (index === 0) {
                    sums[index] = '合计';
                    return;
                }

                if (index == 2) {
                    const values = data.map(item => Number(item["boxCount"]));
                    if (!values.every(value => isNaN(value))) {
                        sums[index] = values.reduce((prev, curr) => {
                            const value = Number(curr);
                            if (!isNaN(value)) {
                                return prev + curr;
                            } else {
                                return prev;
                            }
                        }, 0);
                        sums[index] += ' 箱';
                    } else {
                        sums[index] = 'N/A';
                    }

                }

                if (index == 3) {
                    const values = data.map(item => Number(item["volume"]));
                    if (!values.every(value => isNaN(value))) {
                        sums[index] = values.reduce((prev, curr) => {
                            const value = Number(curr);
                            if (!isNaN(value)) {
                                return prev + curr;
                            } else {
                                return prev;
                            }
                        }, 0);
                        sums[index] += ' (m³)';
                    } else {
                        sums[index] = 'N/A';
                    }

                }
            });


            return sums;
        },
        getData: function() {


            var me = this;


            me.$http.post("/storagebill/staticCount.do", { warehouseId: me.queryParams.warehouseId }).then(response => {

                var body = response;
                if (body.status == 0) {

                    me.billData = body.obj;

                } else {
                    me.errorMessage(body.info);
                }

            }, response => {

            });

        },

        cbstime: function(value) {
            if (value) {
                this.queryParams.btime = value[0];
                this.queryParams.etime = value[1];
            } else {
                this.queryParams.btime = "";
                this.queryParams.etime = "";
            }
        },
        cbotime: function(value) {
            if (value) {
                this.queryParams.botime = value[0];
                this.queryParams.eotime = value[1];
            } else {
                this.queryParams.botime = "";
                this.queryParams.eotime = "";
            }
        },
        cbtime: function(value) {
            if (value) {
                this.queryParams.batime = value[0];
                this.queryParams.eatime = value[1];
            } else {
                this.queryParams.batime = "";
                this.queryParams.eatime = "";
            }
        },

        fitlerWarehouse: function(ware) {
            if (ware) {
                this.queryParams.warehouseId = ware.warehouseId;
            } else {
                this.queryParams.warehouseId = null;
            }
            this.getData();
            this.getList();


        },
        getWarehouses: function() {
            var me = this;
            me.loadingWarehouse = true;

            getWmsList({}).then(response => {
                me.loadingWarehouse = false;
                var body = response;
                if (body.status == 0) {

                    me.warehouses = body.obj;

                } else {
                    me.errorMessage(body.info);
                }

            }, response => {
                me.loadingWarehouse = false;
            });
        },
        toOk(row) {
            this.storageBill = row;

            this.$refs['dialogBill'].showDialog();
        },
        toPay(row) {
            this.$refs['dialogPayBill'].showDialog(row.id);
        },
        doConnect: function(callback) {
            let serviceUrl = "ws://localhost:13528";
            var me = this;
            me.socket = new WebSocket(serviceUrl);

            // 监听消息
            me.socket.onmessage = function(event) {
                console.log('Client received a message', event);

                let data = JSON.parse(event.data);

                if (data.cmd == "getPrinters") {

                    if (!me.printName) {
                        me.printName = data.defaultPrinter;
                        localStorage.setItem("defaultPrinter", me.printName);
                    }
                    me.printers = data.printers;

                } else if (data.cmd == "print") {

                    if (data.msg == "成功" || data.status == "success") {

                        if (data.hasOwnProperty("previewURL")) {
                            window.open(data['previewURL']);
                        } else {
                            iNotify.player("printOk");
                        }

                    } else {
                        iNotify.player("printError")
                    }
                }

            };

            me.socket.onopen = function(event) {
                if (callback != null) {
                    callback();
                }

            }

            me.socket.onerror = function(error) {
                console.log("Failed to connect CN print at " + serviceUrl, error);

            }

            // 监听Socket的关闭
            me.socket.onclose = function(event) {
                console.log('Client notified socket has closed', event);

            };
        },
        initPrint() {

            if (!this.socket || typeof this.socket == "undefined" || this.socket.readyState == WebSocket.CLOSED) {
                this.doConnect(this.initPrint);
                return;
            }
            if (this.socket && typeof this.socket != "undefined" && this.socket.readyState == 1) {
                this.printName = localStorage.getItem("defaultPrinter");
                this.getPrinters();
            } else {
                this.printName = "";
            }
        },
        getPrinters() {
            this.socket.send(JSON.stringify({
                "cmd": "getPrinters",
                "requestID": getRand(),
                "version": "1.0"
            }));
        },
        setDayin() {
            if (!this.socket || typeof this.socket == "undefined" || this.socket.readyState == WebSocket.CLOSED) {
                //
                this.errorMessage("暂未安装打印控件")
                return;
            }
            this.printerShow = true;
        },
        printSetOk: function(name) {
            this.printName = name;
            localStorage.setItem("defaultPrinter", name);
            this.printerShow = false;
        },
        printType: function(cmd, row) {
            if (!this.socket || typeof this.socket == "undefined" || this.socket.readyState == WebSocket.CLOSED) {
                //
                this.errorMessage("暂未安装打印控件")
                return;
            }
            this.storageBill = row;
            if (cmd == "printSku") {
                this.$refs['refPrintSku'].showDialog();
            } else if (cmd == "printBox") {
                this.$refs['refPrintBox'].showDialog();
            }
        },
        skuCallBack: function(data) {
            this.boxCallBack(data);
        },
        boxCallBack: function(data) {
            debugger;
            //data发送
            let time = new Date().getTime() + getRand();
            let printData = {
                "cmd": "print",
                "version": "1.0",
                "requestId": time,
                "task": {
                    "taskID": "tk" + time,
                    "preview": true,
                    "printer": this.printName,
                    "notifyMode": "allInOne",
                    "previewType": "pdf",

                    "documents": data
                }
            }
            this.socket.send(JSON.stringify(printData))

        },
        otherCallBack: function(data) {

            this.boxCallBack(data);

        },
        customPrint: function() {
            if (!this.socket || typeof this.socket == "undefined" || this.socket.readyState == WebSocket.CLOSED) {
                //
                this.errorMessage("暂未安装打印控件")
                return;
            }
            this.$refs['refPrintOther'].showDialog();
        },
        searchOrder: function(state, back) {
            this.queryParams.state = state;
            this.queryParams.back = back;
            this.search();
        },

        search: function() {
            this.page.current = 1;
            this.page.total = 0;
            this.getList();
        },
        reset: function() {
            this.queryParams = {
                state: '',
                back: '',
                counter: "",
                feeState: null
            };
            this.search();
        },
        changePage(current) {
            this.page.current = current;
            this.getList();
        },
        getList: function() {
            var me = this;
            var params = me.queryParams;
            params.current = me.page.current;
            params.pageSize = me.page.pageSize;
            me.loading = true;
            getStorageBillList(params).then(response => {
                var body = response;
                if (body.status == 0) {

                    me.page.total = body.obj.totalCount;
                    me.storageBills = body.obj.list;

                }
                me.loading = false;
            }, response => {
                me.loading = false;
            });
        },
        toModify: function(row) {
            //修改
            // this.$router.push({
            //   name: "StorageBillEdit",
            //  params: {
            //      billId: row.id
            //   }
            // });
            this.$refs['billEditDialog'].showDialog(row.id);
        },
        toDelete: function(row) {
            var me = this;
            me.$Modal.confirm({
                title: "提示",
                content: "是否执行该操作",
                onOk: function() {
                    me.showLoading();
                    me.$http.post("/storagebill/delete.do", { id: row.id }).then(response => {
                        var body = response;
                        if (body.status == 0) {
                            me.getList();
                            me.successMessage("删除成功");
                        } else {
                            me.errorMessage(body.info);
                        }
                        me.hideLoading();
                    }).catch(error => {
                        me.hideLoading();
                    });
                },
                onCancel: function() {

                }
            });
        },
        toShip: function(row) {
            var me = this;
            me.$Modal.confirm({
                title: "提示",
                content: "是否执行该操作，出货之后，将无法取消",
                onOk: function() {
                    me.showLoading();
                    me.$http.post("/storagebill/doShip.do", { id: row.id }).then(response => {
                        var body = response;
                        if (body.status == 0) {
                            me.getList();

                        } else {
                            me.errorMessage(body.info);
                        }
                        me.hideLoading();
                    }).catch(error => {
                        me.hideLoading();
                    });
                },
                onCancel: function() {

                }
            });
        },
        toCancel: function(row) {
            var me = this;
            me.$Modal.confirm({
                title: "提示",
                content: "是否执行该操作",
                onOk: function() {
                    me.showLoading();
                    me.$http.post("/storagebill/doCancel.do", { id: row.id }).then(response => {
                        var body = response;
                        if (body.status == 0) {
                            me.getList();

                        } else {
                            me.errorMessage(body.info);
                        }
                        me.hideLoading();
                    }).catch(error => {
                        me.hideLoading();
                    });
                },
                onCancel: function() {

                }
            });
        },
        add: function() {

            this.$router.push({ name: "StorageBillAdd" })
        }

    }
}
</script>
<style scoped></style>